import { observable, action, toJS, computed } from 'mobx';
import { Tools, Toast, Bubble } from 'weaver-mobile';
import * as goalBase from '../../api/goal/goalBase'
const getLabel = Tools.getLabel
export default class GoalCommonStore {

  @observable selectViewType = "3"
  @observable viewType = [
    {
      key: "4",
      iconclass: "organization",
      title: getLabel(382496, '层级视图')
    },
    {
      key: "3",
      iconclass: "sault",
      title: getLabel(508756, '分类视图')
    },
    {
      key: "1",
      iconclass: "list",
      title: getLabel(82532, '列表视图')
    },
  ]
  
    //组织目标
  @observable orgTypeList = []; //组织卡片下拉列表
  @observable currentOrgId  = "0";//当前组织选项
  @observable isOrgGoal = false //是否为组织目标

  @action
  setIsOrgGoal = (condtype) =>{
      if(condtype == 2 || condtype == 8 || condtype == 9){
          this.isOrgGoal = true;
      }else{
          this.isOrgGoal = false;
      }
  }

  @action
  setSelectViewType = (selectViewType) => {
    this.selectViewType = selectViewType;
  }


  @action
  setOrgtitle = (data)=>{
    this.orgtitle = data;
  }


  @action
  showLoading = () => {
    Toast.loading('Loading...', 0)
  }

  @action
  closeLoading = () => {
    Toast.hide()
  }

  @action
  saveSuccess = (duration, onClose) => {
    Bubble.success(getLabel(22619, '保存成功'), duration || 1, {}, 1, onClose, true)
  }

  @action
  deleteSuccess = (duration, onClose) => {
    Bubble.success(getLabel(83472, '删除成功!'), duration || 1, {}, 1, onClose, true)
  }

  @action
  warn = (content) => {
    Bubble.warning(content, 1)
  }

  @action
  remind = (content) => {
    Bubble.remind(content, 1)
  }

  @action
  updateSuccess = () => {
    Bubble.success(getLabel(31439, '更新成功!'), 1)
  }

  @action
  attentionSuccess = () => {
    Bubble.success(getLabel(503769, '关注成功!'), 1)
  }

  @action
  cancelAttentionSuccess = () => {
    Bubble.success(getLabel(503772, '取消关注成功!'), 1)
  }

}